package java6681.lesson07;

import java.util.Scanner;
class Rectangle6681{
    private int length;
    private int width;
    public Rectangle6681 (){}
    public Rectangle6681 (int length,int width){
        this.width = width;
        this.length = length;
    }
    public void setLength(int length){
        this.length = length;
    }
    public int getLength(){
        return length;
    }
    public void setWidth(int width){
        this.width = width;
    }
    public int getWidth(){
        return width;
    }
    public int calcAllLength(){
        return 2*(length + width);
    }
    public int calcArea(){
       return length * width;
    }
    public String toString(){
        return "length=" +length + "width=" +width;
    }
}
public class Rectangle6681Demo {
    public static void main(String[] args) {
        Rectangle6681 rect1 =new Rectangle6681();
        rect1.setLength(10);
        rect1.setWidth(5);
        System.out.println(rect1.calcAllLength());
        System.out.println(rect1.calcArea());

        Scanner scan = new Scanner(System.in);
        System.out.print("输入长和宽：");
        int l = scan.nextInt();
        int w = scan.nextInt();
        Rectangle6681 rect2 = new Rectangle6681(l,w);
        System.out.println(rect2.calcAllLength());
        System.out.println(rect2.calcArea());


    }
}
